// Sweep
// by BARRAGAN <http://barraganstudio.com> 
// This example code is in the public domain.


#include <Servo.h> 
 
Servo myservo1;  // create servo object to control a servo 
Servo myservo2; 
 
int pos = 0;    // variable to store the servo position 
int counter =0;
int led = 12;
 
void setup() 
{ 
  pinMode(led, OUTPUT);   
  Serial.begin(9600);
  
  myservo1.attach(3);
  myservo1.write(0);
  delay(55); 
  
  myservo2.attach(5);
  myservo2.write(0);
  delay(55); 
} 
 
 
void loop() 
{ 
 if (Serial.available() > 0) 
 {
    int inByte = Serial.read();
    Serial.print("Received: ");
    Serial.println(inByte);
    switch (inByte)
    {
      case 'a': 
        Serial.println("Setting Servo 1 to position 0...");
        myservo1.write(0);  
        delay(60);
        Serial.println("Servo 1 set to position 0!");
  digitalWrite(led, LOW);        
      break;
      
      case 'b':
          Serial.println("Setting Servo 1 in position 1...");
          myservo1.write(176);  
          delay(60); 
          Serial.println("Servo 1 set to position 1!");  
      break;
      
      case 'c': 
        Serial.println("Setting Servo 2 to position 0!");
        myservo2.write(0);  
        delay(60);
        Serial.println("Servo 2 set to position 0!");        
      break;
      
      case 'd':
          Serial.println("Setting Servo 2 to position 1!");
          myservo2.write(176);  
          delay(60);  
          Serial.println("Servo 2 set to position 1!");     
      break;
      
      case 'i':
          Serial.println("Switching Led on...");
          digitalWrite(led, HIGH);  
          delay(5);  
          Serial.println("Led switched on!");     
      break;
      
      case 'j':
          Serial.println("Switching Led off...");
          digitalWrite(led, LOW);  
          delay(5);  
          Serial.println("Led switched off!");     
      break;   
      
      case 'k':
          Serial.println("State of components requested...");
          Serial.print("Servo 1 is in position ");
          Serial.println(myservo1.read());      
          delay(5); 
          Serial.print("Servo 2 is in position ");
          Serial.println(myservo2.read());
          delay(5);
          Serial.print("Led is in state ");
          Serial.println(digitalRead(led));
          
      break;  
      default:
        // mach gar nichts
      break;
    }  
 }
}
 
